package ch.thomasmueller.saltyfiles.ui.command;

import java.awt.event.ActionEvent;
import java.io.File;

import javax.swing.JFileChooser;
import javax.swing.JRadioButton;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;

import ch.thomasmueller.saltyfiles.data.DataField;
import ch.thomasmueller.saltyfiles.data.DataModel;


public class ChooseAlgorithmtCommand  implements Command{

	
	private Logger log = LogManager.getLogger(getClass().getName());

	/**
	 * Switches betwenn encript and decript mode.
	 * @see ch.thomasmueller.saltyfiles.ui.command.Command#doCommand(ActionEvent)
	 */
	public void doCommand(ActionEvent event)
	{

			DataField algorithmDataField = DataModel.getInstance()
					.getDataField(DataModel.ALGORITHM);
			if (algorithmDataField  == null)
			{
				throw new RuntimeException("DataField not registered " 
						+ DataModel.ALGORITHM);			
			}
			else
			{
				String algorithm = ((JRadioButton) event.getSource()).getText();
				algorithmDataField.setValue(algorithm);
				log.debug("Algorithm is: " +algorithm);
			}

	}
	
}
